<template>
<div class="warpper">
    <header>
        <p>我的订单</p>
    </header>
    <h3>未支付订单信息：</h3>
    <ul class="order-List">
        <li v-for="item in orderArr" v-bind:key="item.orderId">
            <div v-if="item.orderState == 0">
                <div class="order-info">
                    <p>
                        {{ item.business.businessName }}
                        <i class="fa fa-caret-down" @click="detailetShow(item)"></i>
                    </p>
                    <div class="order-info-right">
                        <p>&#165;{{ item.orderTotal }}</p>
                        <div class="order-info-right-icon">去支付</div>
                    </div>
                </div>
                <ul class="order-detailet" v-show="item.isShowDetailet">
                    <li v-for="odItem in item.odList" v-bind:key="odItem.orderId">
                        <p>{{ odItem.food.foodName}}X{{ odItem.quantity }}</p>
                        <p>&#165;{{ odItem.food.foodPrice*odItem.quantity }}</p>
                    </li>
                    <li>
                        <p>配送费</p>
                        <p>&#165;{{ item.business.deliveryPrice }}</p>
                    </li>
                </ul>
            </div>
        </li>
    </ul>
    <h3>已支付的订单信息：</h3>
    <ul class="order-List">
        <li v-for="item in orderArr" v-bind:key="item.orderId">
            <div v-if="item.orderState==1">
            <div class="order-info">
                <p>
                    {{ item.business.businessName }}
                    <i class="fa fa-caret-dowm" @click="detailetShow(item)"></i>
                </p>
                <div class="order-info-right">
                    <p>&#165;{{ item.orderTotal }}</p>
                </div>
            </div>
            <ul class="order-detailet" v-show="item.isShowDetailet">
                <li v-for="odItem in item.odList" v-bind:key="odItem.orderId">
                    <p>{{ odItem.food.foodName }}X{{ odItem.quantity }}</p>
                    <p>&#165;{{ odItem.food.foodPrice*odItem.quantity }}</p>
                </li>
                <li>
                    <p>配送费</p>
                    <p>&#165;{{ item.business.deliveryPrice }}</p>
                </li>
            </ul>
            </div>
        </li>
    </ul>
    <Footer></Footer>
</div>
</template>
<script>
export default{
    name:'OrderList',
    data(){
        return{
            orderArr:[],
            user:{}
        }
    },
    created(){
        this.user = this.$getSessionStorage("user");
        this.$axios.post('OrdersController/listOrderByUserId',this.$qs.stringify({
            userId:this.user.userId
        })).then(response =>{
            let result = response.data;
            for(let orders of result){
                orders.isShowDetailet = false;
            }
            this.orderArr = result;
            console.log(this.orderArr);
            
        }).catch(error =>{
            console.error(error);
            
        })
    },
    methods:{
        detailetShow(orders){
            orders.isShowDetailet = !orders.isShowDetailet;
        }
    }
}
</script>
<style>

.order-info-right-icon{
    background-color: #d0af95;
    color: white;
    
}

</style>